<template>
  <div>
    <input type="text" v-if="showInput" id="ipt" ref="ipt" />
    <button @click="handleShow" ref="btn">点击搜索</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showInput: false,
    }
  },
  methods: {
    handleShow() {
      this.showInput = true
      this.$nextTick( () => {
        this.$refs.ipt.focus()
     })
    },
  },
}
</script>

<style></style>
